package com.ruoyi.ysVideo.service.impl;

import com.ruoyi.ysVideo.domain.*;
import com.ruoyi.ysVideo.mapper.EzvizMapper;
import com.ruoyi.ysVideo.service.EzvizService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: class by cxf
 * @author: AbrahamBill
 * @date: 2022/9/2
 **/
@Slf4j
@Service
public class EzvizServiceImpl implements EzvizService {
    @Autowired
    private EzvizMapper ezvizMapper;

    //返回app_key与app_secret
    public AppInfo selectMyAppInfo(String deviceSerial){
        return ezvizMapper.selectMyAppInfo(deviceSerial);
    }

    //插入一张图片抓拍信息
    public int insertMyCaptureImg(MyVideoImg myVideoImg){
        return ezvizMapper.insertMyCaptureImg(myVideoImg);
    }

    //根据id删除数据库图片记录（没有删除服务器上的图片，只是删除记录）
    public int deleteMyImgById(int id){
        return ezvizMapper.deleteMyImgById(id);
    }

    //根据设备序列号获取图片列表
    public List<ImgInfo> selectMyCaptureImgList(String deviceSerial){
        List<ImgInfo> res = ezvizMapper.selectMyCaptureImgList(deviceSerial);
        res.forEach(ImgInfo::init_sum);
        return res;
    }
    //根据用户名获取该用户下的所有设备
    public List<String> selectDevicesByUserName(String userName){
        return ezvizMapper.selectDevicesByUserName(userName);
    }
    //新增预置点
    public int insertMyPreset(MyPresetInfo myPresetInfo){
        return ezvizMapper.insertMyPreset(myPresetInfo);
    }
    //清除预置点
    public int deleteMyPreset(MyPresetInfo myPresetInfo){
        return ezvizMapper.deleteMyPreset(myPresetInfo);
    }
    //清除预制点相关的定时任务
    public int deleteMyAutoTask(MyPresetInfo myPresetInfo){
        return ezvizMapper.deleteMyAutoTask(myPresetInfo);
    }
    //根据设备序列号查询所有预置点位
    public List<MyPresetInfo> selectMyPresetBySerial(MyPresetInfo myPresetInfo){
        return ezvizMapper.selectMyPresetBySerial(myPresetInfo);
    }
    //根据设备序列号更新设备名称
    public int updateRemarkName(MyDeviceName myDeviceName){
        return ezvizMapper.updateRemarkName(myDeviceName);
    }
    //根据用户查询设备信息
    public List<MyDeviceName> selectMyDeviceNameByUser(String userName){
        return ezvizMapper.selectMyDeviceNameByUser(userName);
    }

    // 更新设备状态
    public int updateDeviceStatusInfo(MyDeviceUpdateStatus status){
        return ezvizMapper.updateDeviceStatusInfo(status);
    }
}
